<?php
namespace Home\Controller;
use Think\Controller;
use Think\Page;

/*
* 周边景区
*/
class ScenicController extends CommonController {
  private $article_model;

  var $map_list = array(
		'北京'=>'39.910837,116.413624',
  		'宁波'=>'29.879748,121.55486',
  		'南京'=>'32.065804,118.792447',
  		'杭州'=>'30.279955,120.164183',
  		'上海'=>'31.236565,121.480425',
  		'湖州'=>'30.893545,120.100448',
  		'苏州'=>'31.336988,120.617032',
  		'嘉兴'=>'30.771137,120.769339',
  		'温州'=>'27.987783,120.69006',
  		'桐乡'=>'30.636146,120.571546',
  					
	);
  
  public function _initialize(){
    parent::_initialize();

    $this->article_model = M('Article');
  }

  //周边景区-》默认乌镇
  public function index(){
    $article = $this->article_model->find(51);
    $article = $this->check_EN_ZH($article);
    $template_params['download'] = false;
    $this->assign('article',$article);
    $this->display('Scenic/index');
  }

  //点击周边旅游相册中看具体照片
  public function album(){
  	
  	$template_params['action'] = 'nearby';
    $this->assign('template_params',$template_params);
  	
  	$photo = M('Photos');
  	$id = $_GET['id'];
  	$this->assign('art_id',$id);
  	$article = $this->article_model->find($id);
  	$article = $this->check_EN_ZH($article);
  	$this->assign('article',$article);
  	
  	
  	$photoList = $photo->where('photoable="viewspot" and photoable_id='.$id)->order('created_at desc')->select();
  	$this->assign('photoList',$photoList);
  	
    $this->display('Scenic/album');
  }

  //点击周边旅游相册中看具体照片
  public function show(){
    $this->display('Scenic/show');
  }

  //周边景区-》东栅
  public function dongzha(){
    $template_params['action'] = __FUNCTION__;
    $template_params['download'] = "/Public/images/dongzha_map.jpg";

    $article = $this->article_model->find(52);
	$article = $this->check_EN_ZH($article);
    
    $this->assign('article',$article);
    $this->assign('template_params',$template_params);
    $this->display('Scenic/index');
  }

  //周边景区-》西栅
  public function xizha(){
    $template_params['action'] = __FUNCTION__;
    $template_params['download'] = "/Public/images/xizha_map.jpg";

    $article = $this->article_model->find(53);
	$article = $this->check_EN_ZH($article);
    
    $this->assign('article',$article);
    $this->assign('template_params',$template_params);
    $this->display('Scenic/index');
  }

  //周边景区-》周边旅游
  public function nearby(){
    $template_params['action'] = __FUNCTION__;
    $this->assign('template_params',$template_params);
    
    $count      = $this->article_model-> where('flag="viewspot" and id != 51 and id != 52 and id != 53')->count();// 查询满足要求的总记录数
	$Page       = new Page($count,9);// 实例化分页类 传入总记录数和每页显示的记录数
	$show       = $Page->show();// 分页显示输出
    $articles = $this->article_model->where('flag="viewspot" and id != 51 and id != 52 and id != 53')->limit($Page->firstRow.','.$Page->listRows)->order('created_at desc')->select();
	foreach ($articles as $i => $article){
		$articles[$i] = $this->check_EN_ZH($article);
	}
	$this->assign('page',$show);
	$this->assign('articles',$articles);
	
    $this->display('Scenic/other');
  }

  //周边景区-》交通导航
  public function map(){
 	$template_params['action'] = __FUNCTION__;
    $this->assign('template_params',$template_params);
    
    $this->assign('map_list',$this->map_list);
   
	
    $this->display('Scenic/map');
  }

}